﻿/*
 * This software is the confidential and proprietary
 * information of NetBay
 * Such confidential information should not be disclosed
 * NetBay copyright(c) 2010
 */

#region Using
using System;
using System.Collections.Generic;

#endregion

namespace Rio.Framework.RioManager
{
    /// <summary>
    /// Class handle 'Rio.Manager'
    /// </summary>
    public static class MainManager
    {

        /// <summary>
        /// Initialize all manager modules
        /// </summary>
        /// <param name="p_sDirectoryDA">Configuration file's directory for DataAccess and logger</param>
        /// <param name="p_sFileNameDA">Configuration's name for DataAccess and logger</param>
        /// <param name="p_sDataBaseConnectionDA">Alias of Connexionstring for DataAccess</param>
        /// <param name="p_sCulture">Default culture</param>
        /// <param name="p_oAppSettings">The app settings.</param>
        /// <returns></returns>
        public static bool Init(string p_sDirectoryDA, string p_sFileNameDA, string p_sDataBaseConnectionDA, string p_sCulture, Dictionary<string, string> p_oAppSettings)
        {
            bool l_bRet = false;
            try
            {
                // Initialize the LoggerManager
                LoggerManager.Init(p_sDirectoryDA, p_sFileNameDA);
                // Get the package name from web config file

                // Initialize the LanguageManager
                LanguageManager.Init(p_sCulture);

                // Important : call this initialization before others who need an access to DB
                DataAccessManager.Init(p_sDirectoryDA, p_sFileNameDA, p_sDataBaseConnectionDA);

                //// Get the package name from web config file
                //string l_sPackageName = string.Empty;

                // Initialize the SettingsManager
                l_bRet = SettingsManager.Init(p_sDataBaseConnectionDA);

                // Add AppSettings to SettingsManager
                SettingsManager.DeploymentConfigurations = p_oAppSettings;

                //// Initialize the ParamMessageFlow
                //if (l_bRet == true)
                //{
                //    l_bRet = FlowManager.Init(l_sPackageName);
                //}
            }
            catch (Exception ex)
            {
                LoggerManager.GetBusinessLogger.LogError("(p_sDirectoryDA<" + p_sDirectoryDA + "> p_sFileNameDA<" + p_sFileNameDA + "> p_sDataBaseConnectionDA<" + p_sDataBaseConnectionDA + ">) EXCEPTION -> " + Environment.NewLine + ex);
            }

            return l_bRet;
        }
    }
}
